<?php

	$TEMP->set_file(array('handle' => DIR_IFRAME_VIEW . 'editStudentSection.html'));
	
	$studID 	= $_GET['id'];
	$semLinkID	= $_GET['slid'];
	
	$strStudPictureName = $globalCon->getStudentPictureName($studID);
	$strName			= $strStudPictureName['name'];
	$strAccNo			= $strStudPictureName['stud_no'];
	$courseID			= $strStudPictureName['course_idPK'];
	$courseCode			= $strStudPictureName['course_code'];
	$courseDesc			= $strStudPictureName['course_desc'];
	
	$studentSection = $globalCon->getStudentSection($studID, $semLinkID, $activeYear);
	$sectionID		= $studentSection['section_idPK'];
	$sectionDesc	= $studentSection['section_desc'];
	$sectionSemID 	= $studentSection['stud_sem_idPK'];
	
	if ( isset($_POST['subButton']) ) {
		$if_error	= 0;
		$txtsection	 = _POST('txtsection');
		if ( empty($txtsection) )	 { $if_error++; $_txtsection 	= REQ_FIELD; }
		if ( $if_error == 0 ) {
			
			$STUD->updateStudentSection($txtsection, $sectionSemID, $courseID, $semLinkID);
			$if_display = 1;
		}
	}
	else {
		$if_display	 = 0;
		$if_error	 = 0;
		$_txtsection = '';
	}
	
	$profSectionList = $STUD->getProfSectionList('', $semLinkID);
	$selectSectionList = '<select name="txtsection" id="txtsection" class="select-auto-input">';
	$selectSectionList .= '<option value="" class="color-grey">--- SECTIONS ---</option>';
		if ( !empty($profSectionList) ) {
			foreach($profSectionList as $profSectionListValue) {
				$selectSectionList .= '<option value="' . $profSectionListValue['section_idPK'] . '" ' . $selectedSection . '>' . $profSectionListValue['section_desc'] . '</option>';
			}
		}
	$selectSectionList .= '</select>';
	
	$TEMP->set_var(array('section'		=> $selectSectionList,
						 'section_desc'	=> $sectionDesc,
						 'course_label'	=> $courseDesc . ' (' . $courseCode . ')',
						 'sy_label'		=> $__SYR__,
						 'name'			=> $strName,
						 'if_display'	=> $if_display,
						 'w_txtsection' => $_txtsection
						));

?>